Socket
Socket
Sign inDemoInstall

remove-trailing-separator

Package Overview
Dependencies
0
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    remove-trailing-separator

Removes separators from the end of the string.


Version published
Weekly downloads
12M
decreased by-2.81%
Maintainers
1
Install size
4.99 kB
Created
Weekly downloads
 

Package description

What is remove-trailing-separator?

The remove-trailing-separator npm package is a simple utility that helps in removing trailing separators from a given path string. This can be particularly useful in file path manipulations where consistency in path formatting is required.

What are remove-trailing-separator's main functionalities?

Remove trailing path separator

This feature allows the removal of trailing slashes (or other relevant separators) from a file path. It ensures that the path is normalized without an ending separator, which is useful for concatenating paths or when directories are compared.

const removeTrailingSeparator = require('remove-trailing-separator');
console.log(removeTrailingSeparator('example/path/')); // Outputs: 'example/path'

Other packages similar to remove-trailing-separator

Readme

Source

remove-trailing-separator

NPM version Build Status: Linux Build Status: Windows Coverage Status

Removes all separators from the end of a string.

Install

npm install remove-trailing-separator

Examples

const removeTrailingSeparator = require('remove-trailing-separator');

removeTrailingSeparator('/foo/bar/')   // '/foo/bar'
removeTrailingSeparator('/foo/bar///') // '/foo/bar'

// leaves only/last separator
removeTrailingSeparator('/')    // '/'
removeTrailingSeparator('///')  // '/'

// returns empty string
removeTrailingSeparator('') // ''

Notable backslash, or win32 separator behavior

\ is considered a separator only on WIN32 systems. All POSIX compliant systems see backslash as a valid file name character, so it would break POSIX compliance to remove it there.

In practice, this means that this code will return different things depending on what system it runs on:

removeTrailingSeparator('\\foo\\')
// UNIX  => '\\foo\\'
// WIN32 => '\\foo'

Keywords

FAQs

Last updated on 16 Aug 2017

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc